package com.neuralnoise.hibernate.liveJournal;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class AbstractInterest implements java.io.Serializable {

	private static final long serialVersionUID = 2934237099193729291L;
	
	private Integer intid;
	private Integer intcount;
	private String interest;
	
	private Set<Journal> journals = new HashSet<Journal>(0);

	public AbstractInterest() { }
	
	public AbstractInterest(Integer intid, Integer intcount, String interest) {
		this.intid = intid;
		this.intcount = intcount;
		this.interest = interest;
	}
	
	public AbstractInterest(Integer intid, Integer intcount, String interest,
			Set<Journal> journals) {
		this.intid = intid;
		this.intcount = intcount;
		this.interest = interest;
		this.journals = journals;
	}

	@Id
	@Column(name = "intid", unique = true, nullable = false)
	public Integer getIntid() {
		return this.intid;
	}

	public void setIntid(Integer intid) {
		this.intid = intid;
	}

	@Column(name = "intcount", nullable = false)
	public Integer getIntcount() {
		return this.intcount;
	}

	public void setIntcount(Integer intcount) {
		this.intcount = intcount;
	}

	@Column(name = "interest", nullable = false, length = 256)
	public String getInterest() {
		return this.interest;
	}

	public void setInterest(String interest) {
		this.interest = interest;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "interests")
	public Set<Journal> getJournals() {
		return this.journals;
	}

	public void setJournals(Set<Journal> journals) {
		this.journals = journals;
	}

}